
import SysUserService from "../../service/sys/SysUserService";
import Result from "../../vo/Result";

const { Router } = require('express')

const router = Router()

router.post('/api/login', function (req, res) {
  let user=SysUserService.login(req.body);
  if(user){
    return Result.ok(res,user)
  }else {
    return  Result.err(res,"用户名或者密码错误!");
  }
})

router.get('/api/sys/user/one', function (req, res) {
  return Result.ok(res,SysUserService.one(req.query.id))
})

router.get('/api/sys/user/list', function (req, res) {
  return Result.ok(res,SysUserService.list(req.query))
})

router.post('/api/sys/user/update', function (req, res) {
  return Result.ok(res,SysUserService.update(req.body))
})

router.delete('/api/sys/user/delete', function (req, res) {
  return Result.ok(res,SysUserService.delete(req.query.id))
})

module.exports = router
